package com.atguigu.springcloud.alibaba.config;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.DefaultBlockExceptionHandler;
import com.alibaba.csp.sentinel.adapter.spring.webmvc.config.SentinelWebMvcConfig;
import com.atguigu.springcloud.alibaba.myhandler.myHandler;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;

@Configuration
public class MyConfig {

//    @Bean
//    public SentinelWebMvcConfig sentinelWebMvcConfig() {
//        SentinelWebMvcConfig sentinelWebMvcConfig = new SentinelWebMvcConfig();
//        sentinelWebMvcConfig
//                .setBlockExceptionHandler(new myHandler());
//        System.out.println("设置我的默认handler");
//        return sentinelWebMvcConfig;
//    }


    @Bean(value = "restTemplate")
    RestTemplate restTemplate(RestTemplateBuilder builder) {
        return builder.build();
    }
    @Bean(value = "restTemplate1")
    @LoadBalanced
    RestTemplate restTemplat1(RestTemplateBuilder builder) {
        return builder.build();
    }
}
